package com.jindun.common;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.jindun.paper.model.Users;



public class ContextUtil {
	 private static ApplicationContext context;
	 private static Users currentUser;
	 
	 public static ApplicationContext getContext() {
		 if (context == null) {
			 context = new ClassPathXmlApplicationContext("applicationContext.xml");
		 }
		 return context;
	 }
	 
	 public static <T> T getBean(Class<T>  clazz) {
		 return getContext().getBean(clazz);
	 }
	 
	 public void setContext(ApplicationContext context) {
		 ContextUtil.context = context;
	 }
	 
	 public static void setCurrentUser(Users user) {
		 ContextUtil.currentUser = user;
	 }
	 
	 public static Users getCurrentUser() {
		 return currentUser;
	 }
}
